{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "d = dict()\n",
    "d[2] = 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "del d[2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/custom-sort-string\n",
    "\n",
    "\n",
    "\n",
    "Runtime: 56 ms, faster than 6.43% of Python3 online submissions for Custom Sort String.\n",
    "Memory Usage: 14.3 MB, less than 55.69% of Python3 online submissions for Custom Sort String.\n",
    "\n",
    "\n",
    "\n",
    "```python\n",
    "class Solution:\n",
    "    def customSortString(self, S: str, T: str) -> str:\n",
    "        #6:24\n",
    "        d = dict()\n",
    "        for c in T:\n",
    "            if c in d:\n",
    "                d[c] += 1\n",
    "            else:\n",
    "                d[c] = 1\n",
    "        r = \"\"\n",
    "        for c in S:\n",
    "            if c in d:\n",
    "                r += d[c]*c\n",
    "                del d[c]\n",
    "        for c, counting in d.items():\n",
    "            r += c*counting\n",
    "        return r\n",
    "        #6:30\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
